function formatDate(longDate){
    var date = new Date(longDate);
    var yyyy = date.getFullYear();
    var mm = date.getMonth() + 1;
    if (mm < 10) {
        mm = "0" + mm;
    }
    var dd = date.getDate();
    if (dd < 10) {
        dd = "0" + dd;
    }
    return yyyy + "-" + mm + "-" + dd;
}
function isValidateDate(date) {
    date = $.trim(date);
    var reg = /^(\d{4})-(\d{2})-(\d{2})$/;
    reg.exec(date);
    if (!reg.test(date) && RegExp.$2 <= 12 && RegExp.$3 <= 31) {
        return false;
    }
    var year, month, day;
    year = parseInt(date.split("-")[0], 10);
    month = parseInt(date.split("-")[1], 10);
    day = parseInt(date.split("-")[2], 10);
    if (! ((1 <= month) && (12 >= month) && (31 >= day) && (1 <= day))) {
        return false;
    }
    if ((month <= 7) && ((month % 2) == 0) && (day >= 31)) {
        return false;
    }
    if ((month >= 8) && ((month % 2) == 1) && (day >= 31)) {
        return false;
    }
    if (month == 2) {
        if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) {
            if (day > 29) {
                return false;
            }
        } else {
            if (day > 28) {
                return false;
            }
        }
    }
    return true;
}
